package yunquan.wang.modules.base.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.support.RequestContextUtils;

@Controller
public class MainController {
	@RequestMapping(value = "/login.do")
	public String login()
	{
		return "login";
	}
	@RequestMapping(value = "/main.do")
	public String main(HttpServletRequest request, HttpServletResponse response)
	{
		String newLocale = request.getParameter("lang");
		if (newLocale != null) {
			LocaleResolver localeResolver = RequestContextUtils.getLocaleResolver(request);
			if (localeResolver == null) {
				throw new IllegalStateException("No LocaleResolver found: not in a DispatcherServlet request?");
			}
			localeResolver.setLocale(request, response, StringUtils.parseLocaleString(newLocale));
		}
		return "main";
	}
}

/**
 * Copyright (c) 2009,天安怡和 All rights reserved.
 */